<?php


namespace app\shop\validate;


use think\Validate;

class UserValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     * @var array
     */
    protected $rule = [
        'mobile' => 'require|mobile',
        'realname' => 'require',
        'password' => 'require|confirm',
        'sms_code' => 'require',
        'img_code' => 'require',
        'login_type' => 'require|in:0,1',
        'login_code' => 'require',
        'uniqid' => 'require',
        'department_id' => 'require',
        'morning_start_work_time' => 'require',
        'morning_end_work_time' => 'require',
        'afternoon_start_work_time' => 'require',
        'afternoon_end_work_time' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     * @var array
     */
    protected $message = [
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式错误',
        'realname.require' => '昵称不能为空',
        'password.require' => '密码不能为空',
        'password.confirm' => '两次密码不一致',
        'img_code.require' => '图形验证码不能为空',
        'login_type.require' => '请选择登录方式',
        'login_type.in' => '登录方式错误',
        'login_code.require' => '登录码不能为空',
        'uniqid.require' => '图形验证码不能为空',
        'department_id.require' => '部门不能为空',
        'morning_start_work_time.require' => '上班时间不能为空',
        'afternoon_end_work_time.require' => '下班时间不能为空',
        'user_id.require' => '请选择用户',
        'user_id.array' => '用户参数错误',
    ];

    protected $scene = [
        'apiRegister' => ['mobile', 'password', 'realname', 'sms_code'],
        'apiLogin' => ['mobile', 'img_code', 'login_type'],
        'apiRetrieve' => ['mobile', 'password', 'sms_code'],
        'apisaleAdd' => ['mobile', 'realname', 'department_id'],
        'loginCode' => ['login_code'],
        'addLoginCode' => ['user_id', 'morning_start_work_time', 'afternoon_end_work_time'],
        'pcRegister' => ['mobile', 'password', 'sms_code'],
        'pcLogin' => ['mobile', 'login_type'],
    ];
}